﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Threading.Tasks;

namespace HometaskWorkWithFilesBeginning
{
    class Program
    {
        static void Main(string[] args)
        {

            Directory.GetFiles(@"C:\My Files", "*.txt", SearchOption.TopDirectoryOnly);

            string txtSource = @"c:\My files\HT.txt";

            string textFromFileFirst = File.ReadAllText(txtSource);

            string textFromFileFinal = textFromFileFirst.Replace("\r\n\r\n", " ").Replace(",", "").Replace(".", "").Replace("(", "").Replace(")", "");

            string[] wordsFromTextOfFile = textFromFileFinal.Split(' ');
            Console.WriteLine("Количество слов в текстовом файле: {0}", wordsFromTextOfFile.Length);

            string longestWord = "a";
            for (int i = 0; i < wordsFromTextOfFile.Length; i++)
            {
                if (longestWord.Length < wordsFromTextOfFile[i].Length)
                    longestWord = wordsFromTextOfFile[i];
            }
            Console.WriteLine();
            Console.WriteLine("Самое длинное слово в тексте: {0}", longestWord);

            Console.ReadKey();
        }
    }
}
